package com.ruoyi.activity.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.activity.model.domain.Workinformation;
import com.ruoyi.activity.service.IWorkinformationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 参赛信息Controller
 * 
 * @author ruoyi
 * @date 2024-06-29
 */
@RestController
@RequestMapping("/activity/workinformation")
public class WorkinformationController extends BaseController
{
    @Autowired
    private IWorkinformationService workinformationService;

    /**
     * 查询参赛信息列表
     */
    @PreAuthorize("@ss.hasPermi('activity:workinformation:list')")
    @GetMapping("/list")
    public TableDataInfo list(Workinformation workinformation)
    {
        startPage();
        List<Workinformation> list = workinformationService.selectWorkinformationList(workinformation);
        return getDataTable(list);
    }

    /**
     * 导出参赛信息列表
     */
    @PreAuthorize("@ss.hasPermi('activity:workinformation:export')")
    @Log(title = "参赛信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Workinformation workinformation)
    {
        List<Workinformation> list = workinformationService.selectWorkinformationList(workinformation);
        ExcelUtil<Workinformation> util = new ExcelUtil<Workinformation>(Workinformation.class);
        util.exportExcel(response, list, "参赛信息数据");
    }

    /**
     * 获取参赛信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('activity:workinformation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult  getInfo(@PathVariable("id") Long id)
    {
        return success(workinformationService.selectWorkinformationById(id));
    }

    /**
     * 新增参赛信息
     */
    @PreAuthorize("@ss.hasPermi('activity:workinformation:add')")
    @Log(title = "参赛信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult  add(@RequestBody Workinformation workinformation)
    {
        return toAjax(workinformationService.insertWorkinformation(workinformation));
    }

    /**
     * 修改参赛信息
     */
    @PreAuthorize("@ss.hasPermi('activity:workinformation:edit')")
    @Log(title = "参赛信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult  edit(@RequestBody Workinformation workinformation)
    {
        return toAjax(workinformationService.updateWorkinformation(workinformation));
    }

    /**
     * 删除参赛信息
     */
    @PreAuthorize("@ss.hasPermi('activity:workinformation:remove')")
    @Log(title = "参赛信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult  remove(@PathVariable Long[] ids)
    {
        return toAjax(workinformationService.deleteWorkinformationByIds(ids));
    }
}
